<?php

namespace app\studio\controller;

use app\studio\model\DistrictModel;
use app\studio\model\StudioModel;
use cmf\controller\BaseController;


class CommonController extends BaseController
{


    //根据地区id，获取子地区数据                     
    public function getChildrenData()
    {
        $id = $this->request->param('id', 0, 'intval');
        $district = new DistrictModel;
        //查询所有子地区
        $children = $district->field('id,district_name')->where('parent_id', $id)->select();
        //$this->assign('children', $children); //传送数据
        return json($children);
        //return $this->fetch();
    }

    //根据地区id，获取地区的全称
    public function getFullName()
    {
        $id = $this->request->param('id', 0, 'intval');
        $district = new DistrictModel;
        //查询一条地区全称
        $fullName = $district->field('id,full_district_name')->where('id', $id)->find();
        $this->assign('fullName', $fullName); //传送数据
        return json($fullName);
    }

}
